﻿using CommunergyLogic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Practices.Unity;
using Communergy.Common;
using Communergy.Repository;
using Communergy.Data;
using System;
using System.Collections.Generic;
using Communergy.UnitTesting;

namespace CommunergyLogicTests
{
    
    
    /// <summary>
    ///This is a test class for DataAccessLayerTest and is intended
    ///to contain all DataAccessLayerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class DataAccessLayerTest
    {



        /// <summary>
        ///A test for SaveMeterDetails
        ///</summary>
        [TestMethod()]
        public void DataAccess_SaveMeterDetails_DetailsSaved()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            Meter meterToSave = null; // TODO: Initialize to an appropriate value
            target.SaveMeterDetails(meterToSave);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for RetrieveMeterDetails
        ///</summary>
        [TestMethod()]
        public void RetrieveMeterDetailsTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            Meter expected = null; // TODO: Initialize to an appropriate value
            Meter actual;
            actual = target.RetrieveMeterDetails(meterId);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for Insert_ElectricityRealtime
        ///</summary>
        [TestMethod()]
        public void Insert_ElectricityRealtimeTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            MockUnitOfWork unitOfWork =(MockUnitOfWork) repositoryFactory.CreateUnitOfWork();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory);
            string meterId = UnitTestHelper.RandomString(10);
            int recordsToCreate = UnitTestHelper.RandomInt(100, 1000);
            var realtimeEnergyReadings = CommunergyTestHelper.CreateRealtimeRecords(recordsToCreate, 6, DateTime.Now);
            var initialRecords = unitOfWork.RealtimeCommitted.Count;

            target.Insert_ElectricityRealtime(meterId, realtimeEnergyReadings);
            int expectedRecords = initialRecords + recordsToCreate;
            Assert.AreEqual(expectedRecords, unitOfWork.RealtimeCommitted.Count);
        }

        /// <summary>
        ///A test for Insert_ElectricityMonthly
        ///</summary>
        [TestMethod()]
        public void Insert_ElectricityMonthlyTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            List<HistoricalEnergyReading> monthlyEnergyReadings = null; // TODO: Initialize to an appropriate value
            target.Insert_ElectricityMonthly(meterId, monthlyEnergyReadings);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for Insert_ElectricityHourly
        ///</summary>
        [TestMethod()]
        public void Insert_ElectricityHourlyTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            List<HistoricalEnergyReading> hourlyEnergyReadings = null; // TODO: Initialize to an appropriate value
            target.Insert_ElectricityHourly(meterId, hourlyEnergyReadings);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for Insert_ElectricityDaily
        ///</summary>
        [TestMethod()]
        public void Insert_ElectricityDailyTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            List<HistoricalEnergyReading> dailyEnergyReadings = null; // TODO: Initialize to an appropriate value
            target.Insert_ElectricityDaily(meterId, dailyEnergyReadings);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for GetMetersForUser
        ///</summary>
        [TestMethod()]
        public void GetMetersForUserTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string userId = string.Empty; // TODO: Initialize to an appropriate value
            List<Meter> expected = null; // TODO: Initialize to an appropriate value
            List<Meter> actual;
            actual = target.GetMetersForUser(userId);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetLastElectricityRealtime
        ///</summary>
        [TestMethod()]
        public void GetLastElectricityRealtimeTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            RealtimeEnergyReading expected = null; // TODO: Initialize to an appropriate value
            RealtimeEnergyReading actual;
            actual = target.GetLastElectricityRealtime(meterId);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetHourly
        ///</summary>
        [TestMethod()]
        public void GetHourlyTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            DateTime dateFrom = new DateTime(); // TODO: Initialize to an appropriate value
            List<HistoricalEnergyReading> expected = null; // TODO: Initialize to an appropriate value
            List<HistoricalEnergyReading> actual;
            actual = target.GetHourly(meterId, dateFrom);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for Get_ElectricityRealtime
        ///</summary>
        [TestMethod()]
        public void Get_ElectricityRealtimeTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            DateTime dateFrom = new DateTime(); // TODO: Initialize to an appropriate value
            DateTime dateTo = new DateTime(); // TODO: Initialize to an appropriate value
            List<RealtimeEnergyReading> expected = null; // TODO: Initialize to an appropriate value
            List<RealtimeEnergyReading> actual;
            actual = target.Get_ElectricityRealtime(meterId, dateFrom, dateTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for CreateNewMeter
        ///</summary>
        [TestMethod()]
        public void DataAccess_CreateNewMeter_NewMeterAdded()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory); // TODO: Initialize to an appropriate value
            Meter meterToCreate = null; // TODO: Initialize to an appropriate value
            Meter expected = null; // TODO: Initialize to an appropriate value
            Meter actual;
            actual = target.CreateNewMeter(meterToCreate);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }



        /// <summary>
        ///A test for GetCumulativeElectricityRealtime
        ///</summary>
        [TestMethod()]
        public void GetCumulativeElectricityRealtimeTest()
        {
            IRepositoryFactory repositoryFactory = new MockRepositoryFactory();
            MockUnitOfWork unitOfWork = (MockUnitOfWork)repositoryFactory.CreateUnitOfWork();
            DataAccessLayer target = new DataAccessLayer(repositoryFactory);

            string meterId = string.Empty; // TODO: Initialize to an appropriate value
            DateTime dateFrom = new DateTime(); // TODO: Initialize to an appropriate value
            DateTime dateTo = new DateTime(); // TODO: Initialize to an appropriate value
            HistoricalEnergyReading expected = null; // TODO: Initialize to an appropriate value
            HistoricalEnergyReading actual;
            actual = target.GetCumulativeElectricityRealtime(meterId, dateFrom, dateTo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
